package org.lanqiao.music.system.service.impl;

import org.lanqiao.music.system.entity.UserMusic;
import org.lanqiao.music.system.dao.UserMusicDao;
import org.lanqiao.music.system.service.UserMusicService;
import org.lanqiao.music.system.vo.MusicVO;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.PageHelper;
import org.lanqiao.music.common.utils.PageDTO;
import javax.annotation.Resource;
import java.util.List;

/**
 * (UserMusic)表服务实现类
 *
 * @author makejava
 * @since 2024-08-15 20:52:13
 */
@Service("userMusicService")
public class UserMusicServiceImpl implements UserMusicService {
    @Resource
    private UserMusicDao userMusicDao;

    /**
     * 通过ID查询单条数据
     * @return 实例对象
     */
    @Override
    public UserMusic queryById( ) {
        return this.userMusicDao.queryById();
    }

    /**
     * 分页查询
     *
     * @param userMusic 筛选条件
     * @return 查询结果
     */
    @Override
    public PageInfo<UserMusic> queryByPage(UserMusic userMusic, PageDTO pageDTO) {
        PageHelper.startPage(pageDTO.getPageNum(),pageDTO.getPageSize());
        PageInfo page = new PageInfo<>(this.userMusicDao.queryAllByLimit(userMusic));
        return page;
    }

    /**
     * 新增数据
     *
     * @param userMusic 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(UserMusic userMusic) {
       return this.userMusicDao.insert(userMusic);
    }

    @Override
    public int deleteById(Integer musicId) {
        return userMusicDao.deleteById(musicId);
    }



    //用户喜欢的音乐
    @Override
    public List<MusicVO> getUserFavoriteMusic(Integer userId) {
        return userMusicDao.getUserFavoriteMusic(userId);
    }
}
